use front_of_house::test1;

use std::fmt::Result;
use std::io::Result as IOResult;

// use std::cmp::Ordering;
// use std::io;
// use std::{cmp::Ordering,io};

// use std::io;
// use std::io::BufRead;
// use std::io::{self,BufRead};

// 类似 import * from 'react';
use std::collections::*;

// 引用根目录下的文件
mod test_use;

fn server_order() {}

mod front_of_house {
    pub struct test1 {
        pub test11: String,
        test111: String,
    }
    impl test1 {
        pub fn test1() -> test1 {
            return test1 {
                test11: String::from("test11"),
                test111: String::from("test111"),
            };
        }
    }
    pub enum test_enum {
        // 内部字段直接都是跟着pub变成公有的
        test_enum1,
        test_enum2,
    }
    pub mod hosting {
        pub fn add_to_waitlist() {}
        fn seat_at_table() {}
    }
    mod serving {
        fn take_order() {}
        fn test() {}
    }
    fn test() {
        // super使用父级条目
        super::server_order();
        crate::server_order();
    }
}

pub fn eat_at_restaurant() {
    // 绝对路径
    crate::front_of_house::hosting::add_to_waitlist();
    // 相对路径
    front_of_house::hosting::add_to_waitlist();
    let mut test1 = front_of_house::test1::test1();
    test1.test11 = String::from("test1111"); // 因为是公共变量所以可以被访问修改
                                             // test1.test111 = String::from("test111111"); // 因为这个不是公共变量所以不能被调用
}

// use引用（遵循私有性原则）绝对路径
use crate::front_of_house::hosting;

// use引用（绝对路径）
// use front_of_house::hosting;

pub trait Summary {
    fn summary1(&self) -> String;
    fn summary2(&self) -> String;
}

pub struct TestTrait {
    pub summary1: String,
    pub summary2: String,
}

impl Summary for TestTrait {
    fn summary1(&self) -> String {
        return String::from("value");
    }

    fn summary2(&self) -> String {
        return String::from("value1");
    }
}
